﻿using HslCommunication.Core;
using PLC.Domain.Enum;
using PLC.Domain.Models;

namespace PLC.Domain.Service.IRepository;

public interface IPLCRepository
{
    /// <summary>
    /// 根据配置获取客户端
    /// </summary>
    /// <param name="plcConfig"></param>
    /// <returns></returns>
    IReadWriteNet GetPlcClient(PLCConfig plcConfig);

    /// <summary>
    /// 写数据
    /// </summary>
    /// <param name="client"></param>
    /// <param name="address"></param>
    /// <param name="value"></param>
    /// <param name="dataType"></param>
    /// <param name="dataEncoding"></param>
    /// <param name="length"></param>
    /// <param name="protocol"></param>
    void WriteData(IReadWriteNet client, string address, string value, EnumDataType dataType,
        EnumDataEncoding dataEncoding = 0, int length = 0, EnumProtocol protocol = 0);

    /// <summary>
    /// 读数据
    /// </summary>
    /// <param name="client"></param>
    /// <param name="address"></param>
    /// <param name="dataType"></param>
    /// <param name="dataEncoding"></param>
    /// <param name="length"></param>
    /// <returns></returns>
    string ReadData(IReadWriteNet client, string address, EnumDataType dataType, EnumDataEncoding dataEncoding = 0,
        int length = 0);


}